#============================================================
#    Item Menu
#============================================================
# - datetime: 2022-10-01 11:13:00
#============================================================
@tool
extends PopupMenu


signal clicked_item(id, item_name)


const MENU_DATA := {
	edit = "edit",
	sep_01 = "---",
	open_explorer = "open explorer",
	sep_02 = "---",
	remove = "remove",
}


func _ready():
	clear()
	for key in MENU_DATA:
		if MENU_DATA[key] == "":
			MENU_DATA[key] = key
		if MENU_DATA[key] != "---":
			add_item(MENU_DATA[key])
		else:
			add_separator()
	
	id_pressed.connect(func(id): 
		self.clicked_item.emit( id, MENU_DATA.values()[id] ) 
	)


func set_item_disabled_by_name(menu_namae:String, disable:bool):
	var id : int = MENU_DATA.values().find(menu_namae)
	if id > -1:
		set_item_disabled(id, disable)

